package com.mayikt;

import java.util.concurrent.atomic.AtomicLong;

/**
 * @ClassName Test002
 * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
 * @Version V1.0
 **/
public class Test002 extends Thread {

    private static AtomicLong atomicLong = new AtomicLong();

    @Override
    public void run() {
        while (atomicLong.get() < 10000) {
            long l = atomicLong.incrementAndGet();// count++
            System.out.println(Thread.currentThread().getName() + "," + l);
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Long startTime = System.currentTimeMillis();
        Test002 t1 = new Test002();
        Test002 t2 = new Test002();
        t1.start();
//        t2.start();
        t1.join();
//        t2.join();
        Long endTime = System.currentTimeMillis();
        System.out.println(endTime - startTime);
    }
}
